babyishfandomcom-20200214-history
Libdrm
| license = |GPL }} | website = }} The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user space programs can use to send commands and data to the GPU, and perform operations like configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure, but since then it has been used by other graphic stack alternatives like Wayland. The Direct Rendering Manager can be compiled into the Linux kernel or loaded via the standard module interface. Overview The Linux Kernel already had an API called fbdev allowing to manage the framebuffer of a graphics adapter, but it couldn't be used to handle the needs of modern 3D accelerated GPU based video cards. These type of cards usually require setting and managing a command queue in the memory of the card (Video RAM) to dispatch commands to the GPU, and also they need a proper management of the buffers and free space of the Video RAM itself. Initially own user space programs (like the X Server) directly managed these resources, but these programs usually acted as if they were the only ones with access to the card's resources. When two or more programs tried to control the same video card at the same time, and set its resources each one in its own way, most times they ended catastrophically. When the Direct Render Manager was first created, the purpose was that multiple programs that would use the resources of the video card cooperate through it. The DRM has exclusive access to the video card's resources, and it's responsible for initializing and maintaining the command queue, the VRAM and any other hardware resource of the GPU. The programs that want to use a GPU send their requests to DRM, which acts as an arbitrator and takes care to avoid possible conflicts. Since then, the scope of DRM has been expanded over the years to cover more functionality previously handled by user space programs, like framebuffer managing and mode setting, memory sharing objects and memory synchronization. These expansions had carried its own specific names, like Graphics Execution Manager (GEM) or Kernel Mode-Setting (KMS), and are often called by these names when referring specifically to its functionality. But they are really parts of the whole kernel DRM subsystem. Software architecture The Direct Rendering Manager resides in kernel space, so the user space programs must use kernel system calls to request its services. However, DRM doesn't define its own customized system calls. Instead, it follows the Unix principle "everything is a file" to expose the GPUs through the filesystem name space using device files under the /dev hierarchy. Each GPU detected by DRM is referred as a DRM device, and a device file /dev/dri/card''X'' (where X'' is a correlative number) is created to interface with the device. The user space programs that want to talk to the GPU must open the file and use ioctl calls to communicate with DRM. Different ioctls correspond to different functions of the DRM API. A library called ''libdrm was created to facilitate the interface of user space applications with the DRM subsystem. This library is merely a wrapper that provides a function written in C for every ioctl of the DRM API, as well as constants, structures and other helper elements. The use of libdrm not only avoids exposing the kernel interface directly to the user space applications, but presents the usual advantages of reusing and sharing code between programs. It consists of two in-kernel drivers: a generic drm driver, and another which has specific support for the GPUs. This pair of drivers allows a userspace client direct access to the video hardware. The entire DRI system enables hardware accelerated 3D rendering, video decoding as well as GPGPU. AGP, PCIe and other graphics cards contain an IOMMU called Graphics address remapping table (GART) which can be used to map various pages of system memory into the GPU's address space. The result is that, at any time, an arbitrary (scattered) subset of the system's RAM pages are accessible to the GPU. API ' is composed out of the System Call Interface of the Linux kernel, the GNU C Library (by GNU), libcgroup, libdrm, libalsa and libevedv (by freedesktop.org).]] The DRM core exports several interfaces to user-space applications, generally intended to be used through corresponding libdrm wrapper functions. In addition, drivers export device-specific interfaces for use by user-space drivers & device-aware applications through ioctls and sysfs files. External interfaces include: memory mapping, context management, DMA operations, AGP management, vblank control, fence management, memory management, and output management. Translation Table Maps Translation Table Maps memory manager developed by Tungsten Graphics. Graphics Execution Manager The Graphics Execution Manager (GEM) is part of the DRM API that allow multiple applications to share graphics device memory resources (called ''GEM objects). GEM ensures conflict-free sharing of data between applications by managing the memory synchronization. In contrary to its name, it executes nothing, it manages graphics memory. KMS driver (Kernel mode setting) The KMS driver is the component which is solely responsible for the mode setting. It is the device driver for a display controller, and it can be distinguished from the device driver of a rendering accelerator. Due to the fact that dies of modern the GPU found on graphics cards for desktop computers integrate "processing logic", "display controller" and "hardware video acceleration" SIP cores, non-technical people don't distinguish between these three very different components. SoCs on the other hand, regularly mix SIP from different developers, and e.g. ARM's Mali SIP does not feature a display controller. For historical reasons, the DRM and the KMS of the Linux kernel were amalgamated into one component. They were split in 2013 for technical reasons. The video explains what a KMS driver is. Render nodes A render node is a character device that exposes a GPU's off-screen rendering and GPGPU capabilities to unprivileged programs, without exposing any display manipulation access. This is the first step in of an effort to decouple the kernel's interfaces for GPUs and display controllers from the obsolete notion of a graphics card. Unprivileged off-screen rendering is presumed by both Wayland and Mir display protocols — only the compositor is entitled to send its output to a display, and rendering on behalf of client programs is outside the scope of these protocols. Universal plane Patches for universal plane were submitted by Intel's Matthew. D. Roper in May 2014. The idea behind universal plane is to expose all types of hardware planes to userspace via one consistent Kernel–user space API. Universal plane brings framebuffers (primary planes), overlays (secondary planes) and cursors (cursor planes) together under the same API. No more type specific ioctls, but common ioctls shared by them all. Universal plane prepares the way for Atomic mode setting and nuclear pageflip. Hardware support All hardware mentioned in the article free and open-source graphics device driver has drm code. As of August 2013, the kernel component of the freedreno driver mainly authored by Rob Clark for Qualcomm's Adreno GPU family, called MSM driver, has been accepted into mainline, and has been available since Linux kernel 3.12. In Linux kernel 3.13 * DRM support for Marvell's ARMADA 510 display subsystem. DRM/i915 obtained support for MIPI Display Serial Interface (DSI) for Linux kernel 3.16. Linux Graphics Stack 2013.svg|The Direct Rendering Manager and components in user space. The Linux Graphics Stack and glamor.svg|Glamor will simplify the X server Linux graphics drivers DRI early.svg|Direct Rendering Infrastructure versus indirect rendering in its early stage: the X server is still rooted because the 2D graphics driver is part of it, and accesses the hardware directly. Linux graphics drivers DRI current.svg|Only the Direct Rendering Manager accesses the graphics hardware. Linux graphics drivers DRI Wayland.svg|In Linux kernel 3.12 render nodes were merged into the DRM. The KMS was split off. Wayland implements direct rendering over EGL. Linux kernel and OpenGL video games.svg|Calculations for rendering are outsourced to the GPU over OpenGL to be done in real-time. Divelopmènt The Direct Rendering Manager is developed within the Linux kernel, and its source code resides in the /drivers/gpu/drm directory of the Linux source code. The subsystem maintainter is Dave Airlie, with other maintainers taking care of specific drivers. As usual in the Linux kernel development, DRM submaintainers and contributors send their patches with new features and bug fixes to the main DRM maintainer which integrates them into its own Linux repository. The DRM maintainer in turn submits all of these patches that are ready to be mainlined to Linus Torvalds whenever a new Linux version is going to be released. Torvalds, as top maintainer of the whole kernel, holds the last word on whether a patch is suitable or not for inclusion in the kernel. For historical reasons, the source code of the libdrm library is maintained under the umbrella of the Mesa project. Històri In 1999, while developing DRI for XFree86, Precision Insight created the first version of DRM for the 3dfx video cards, as a linux kernel patch included within the Mesa source code. Later that year, the DRM code was mainlined in Linux kernel 2.3.18 under the /drivers/char/drm/ directory for character devices. During the following years the number of supported video cards grew. When Linux 2.4.0 was released in January 2001 there was already support for Creative Labs GMX 2000, Intel i810, Matrox G200/G400 and ATI Rage 128, in addition to 3dfx Voodoo3 cards. Zuigèn divelopmènts Render nodes In 2013, as part of GSoC, David Herrmann developed the multiple render nodes feature. His code was added to the Linux kernel version 3.12 as an experimental feature and enabled by default since Linux 3.17. Päkeijs Komponènts Körrènt vörçion: 2.4.67-1ubuntu0.16.04.1 für "Add missing SKL/BXT pci-id's" *libdrm2: Userspace interface to kernel DRM -- rùntaim environmènt (31 KB) *libdrm-amdgpu1: Userspace inteface to amdgpu-specific kernel DRM -- runtime (20 kB) *libdrm-intel1: Userspace inteface to intel-specific kernel DRM -- runtime (60 kB) *libdrm-nouveau2: Userspace inteface to nouveau-specific kernel DRM -- runtime (19 kB) *libdrm-radeon1: Userspace inteface to radeon-specific kernel DRM -- runtime (24 kB) This library implements the userspace interface to the kernel DRM services. DRM stands for "Direct Rendering Manager", which is the kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on Linux to provide hardware-accelerated OpenGL drivers. Pripäriŋ tom@MW-GAMP103240:~$ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: * libdrm: ** libdrm2 / libdrm2:i386 ** libdrm-intel1 / libdrm-intel1:i386 ** libdrm-nouveau2 / libdrm-nouveau2:i386 ** libdrm-radeon1 / libdrm-radeon1:i386 22 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 85.0 MB of archives. After this operation, 8,192 B of additional disk space will be used. Do you want to continue? Y/n y Dawnloudiŋ #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm2 i386 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm2 amd64 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-intel1 i386 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-intel1 amd64 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-nouveau2 i386 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-nouveau2 amd64 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-radeon1 i386 2.4.60-2~ubuntu14.04.1 kB #Get: http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libdrm-radeon1 amd64 2.4.60-2~ubuntu14.04.1 kB Fetched 85.0 MB in 4min 3s (349 kB/s) Instoliŋ (Reading database ... 421746 files and directories currently installed.) Preparing to unpack .../libdrm2_2.4.60-2~ubuntu14.04.1_i386.deb ... De-configuring libdrm2:amd64 (2.4.56-1~ubuntu2) ... Unpacking libdrm2:i386 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm2_2.4.60-2~ubuntu14.04.1_amd64.deb ... Unpacking libdrm2:amd64 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-intel1_2.4.60-2~ubuntu14.04.1_i386.deb ... De-configuring libdrm-intel1:amd64 (2.4.56-1~ubuntu2) ... Unpacking libdrm-intel1:i386 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-intel1_2.4.60-2~ubuntu14.04.1_amd64.deb ... Unpacking libdrm-intel1:amd64 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-nouveau2_2.4.60-2~ubuntu14.04.1_i386.deb ... De-configuring libdrm-nouveau2:amd64 (2.4.56-1~ubuntu2) ... Unpacking libdrm-nouveau2:i386 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-nouveau2_2.4.60-2~ubuntu14.04.1_amd64.deb ... Unpacking libdrm-nouveau2:amd64 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-radeon1_2.4.60-2~ubuntu14.04.1_i386.deb ... De-configuring libdrm-radeon1:amd64 (2.4.56-1~ubuntu2) ... Unpacking libdrm-radeon1:i386 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Preparing to unpack .../libdrm-radeon1_2.4.60-2~ubuntu14.04.1_amd64.deb ... Unpacking libdrm-radeon1:amd64 (2.4.60-2~ubuntu14.04.1) over (2.4.56-1~ubuntu2) ... Setiŋ Setting up libdrm2:amd64 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm2:i386 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-intel1:amd64 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-intel1:i386 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-nouveau2:amd64 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-nouveau2:i386 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-radeon1:amd64 (2.4.60-2~ubuntu14.04.1) ... Setting up libdrm-radeon1:i386 (2.4.60-2~ubuntu14.04.1) ... Si osou * Free and open-source graphics device driver * Mesa 3D * Graphics address remapping table (GART) * Vblank & V-sync References External links *DRM home page *The Direct Rendering Manager: Kernel Support for the Direct Rendering Infrastructure *Linux DRM Developer's Guide *David Herrmann on Splitting DRM and KMS device nodes * * https://01.org/linuxgraphics/community/libdrm Category:Direct Rendering Infrastructure Category:Linux kernel features Category:Interfaces of the Linux kernel